package com.example.userpage.repository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;

@Repository
public class UserMessageRepository {
    @Autowired
    private JdbcTemplate jdbcMessage;

    public Map<String, Object> findByIp(String ip) {
        String sql = "SELECT username, createdTime, image FROM user WHERE ip = ? LIMIT 1";
        return jdbcMessage.queryForMap(sql, ip);
    }
}